package earogya.pharmacy.pharmacy.ws;

import java.io.IOException;

import ca.uhn.hl7v2.HL7Exception;
import earogya.pharmacy.pharmacy.ws.HL7MessageHandler;

public class PharmacyServiceInterface {
	
	public String pharmacyServiceMessage(String msg)throws HL7Exception, 
			IOException{
		
		HL7MessageHandler h=new HL7MessageHandler();
		String message= "MSH|^~\\&|GUI|CSTH|PHA|CSTH|20110610101010||RDE^O11||P|2.5.1\r"
			+ "EVN|O11|20030822172800|||1\r"
			+ "ORC|NE|1000|9999999^RX|||E|40^Q6H^10||20110610101010||||PHR\r"
			+ "RXO|1120||||||||Y\r";
		
		String message1 = "MSH|^~\\&|GUI|CSTH|PHA|CSTH|20110610101010||RDS^O13||P|2.5.1\r"
			+ "EVN|O13|20030822172800|||1\r"
			+"PID|260|22|10006579^^^1^MRN^1||DUCK^DONALD^D||19241010|M||1|111^DUCK ST^^FOWL^CA^999990000^^M|1|8885551212|8885551212|1|2||40007716^^^AccMgr^VN^1|123121234|||||||||||NO \r"
			+"ORC|NE|1002\r"
			+"RXD|4|2010|20110726101010|50|pills|3 times a day|1010|||192929\r";
		String newMessage=this.modifyMessage(msg);
		String ack=h.parser(newMessage);
		return ack;
	}

	private String modifyMessage(String message) {
		String newMessage = null;
		newMessage = message.replaceAll("\n", "\r");
		return newMessage;
	}

}
